// Decompiled with JetBrains decompiler
// Type: RealTimer
// Assembly: FMCommon, Version=1.0.8663.21262, Culture=neutral, PublicKeyToken=null
// MVID: 52773074-FB09-4BA0-8FA9-4782D11D6C17
// Assembly location: /Users/mac/work/RiverGame/com.rivergame.fmframework/Runtime/Plugins/FMCommon.dll

using System;
using System.Diagnostics;

public class RealTimer
{
    private static Stopwatch _watcher;
    private static Func<float> _customTimer;
    private static float _customResetTime;

    public static void Reset()
    {
        RealTimer._customTimer = (Func<float>) null;
        if (RealTimer._watcher == null)
        {
            RealTimer._watcher = Stopwatch.StartNew();
        }
        else
        {
            RealTimer._watcher.Reset();
            RealTimer._watcher.Start();
        }
    }

    public static void Reset(Func<float> customTimer)
    {
        RealTimer._customTimer = customTimer;
        if (RealTimer._customTimer == null)
            return;
        RealTimer._customResetTime = RealTimer._customTimer();
    }

    public static long elapsedMilliseconds
    {
        get
        {
            return RealTimer._customTimer != null ? (long) (((double) RealTimer._customTimer() - (double) RealTimer._customResetTime) * 1000.0) : RealTimer._watcher.ElapsedMilliseconds;
        }
    }

    public static double elapsedSeconds
    {
        get
        {
            return RealTimer._customTimer != null ? (double) RealTimer._customTimer() - (double) RealTimer._customResetTime : RealTimer._watcher.Elapsed.TotalSeconds;
        }
    }
}
